package cn.guat.smartpark.controller;

import cn.guat.smartpark.common.R;
import cn.guat.smartpark.entity.FireDevices;
import cn.guat.smartpark.service.FireDevicesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 消防设备查询
 */

@RestController
@RequestMapping("/devices")
public class FireDevicesController {

    @Autowired
    private FireDevicesService fireDevicesService;

    /**
     * 通过设备id查询设备信息
     * @param deviceId
     * @return
     */
    @GetMapping
    public R<FireDevices> getDevicesById(String deviceId) {
        System.out.println("查询设备id为"+deviceId);
        //查询消防设备
        FireDevices fireDevices=fireDevicesService.getDevicesById(deviceId);
        if(fireDevices != null){
            return R.success(fireDevices);
        }
        return R.error("对象信息获取失败，请稍后重试");
    }
}
